import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 气象数据记录
 */
@Entity('iot_weather_data')
export class IotWeatherDataEntity extends BaseEntity {
  @Index()
  @Column({ comment: '城市编码' })
  cityCode: string;

  @Column({ comment: '城市名称' })
  cityName: string;

  @Column({ comment: '温度', type: 'decimal', precision: 5, scale: 2 })
  temperature: number;

  @Column({ comment: '湿度', type: 'decimal', precision: 5, scale: 2 })
  humidity: number;

  @Column({ comment: '天气现象' })
  weather: string;

  @Column({
    comment: 'PM2.5',
    type: 'decimal',
    precision: 5,
    scale: 2,
    nullable: true,
  })
  pm25: number;

  @Column({ comment: '空气质量指数', nullable: true })
  aqi: number;

  @Column({ comment: '空气质量等级', nullable: true })
  airQuality: string;

  @Column({
    comment: '风速',
    type: 'decimal',
    precision: 5,
    scale: 2,
    nullable: true,
  })
  windSpeed: number;

  @Column({ comment: '风向', nullable: true })
  windDirection: string;

  @Column({ comment: '日出时间', nullable: true })
  sunrise: string;

  @Column({ comment: '日落时间', nullable: true })
  sunset: string;

  @Column({ comment: '采集时间' })
  collectTime: Date;
}
